<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
    <title>文档管理</title>
	<%@ include file="/common/header/meta.jsp"%>
	<%@ include file="/common/header/script.jsp"%>
    <script type="text/javascript">
    var $tree, $parent_box ;
    $(function(){
    	$parent_box = $("#pid").combotree({
			url : $.webapp.root + "/admin/site/column/combo_tree.do",
			idFiled:'pid', textFiled:'name', editable: false, required:false, lines:true, autoShowPanel: false
		}) ;
    	
		$tree = $("#tree").tree({
			url: $.webapp.root + "/admin/site/column/doNotNeedAuth_tree.do",
			method: "get", animate: true, idField: 'id', treeField: 'colName',
			onClick: function(node){
				$dg = $("#dg").datagrid({
					url: $.webapp.root + "/admin/site/doc/doNotNeedAuth_datagrid.do?pid="+node.id,
					idField: 'emp_id', fit: true, border: false, pageSize: 30, pageList: [30,40,50,100,200,1000	], rownumbers: true,
					remoteSort: true, toolbar: '#toolbars', striped:true, pagination: true, singleSelect: false,
					sortName: 'num', sortOrder: 'asc',
					frozenColumns: [[
					    { field: 'ck', checkbox: true },
					    { field: 'id', title: 'ID', width: 80, hidden: true }
					]],
					columns: [[
					    { field: 'pageLogo', title: 'LOGO', width: 100, align: 'center' },
					    { field: 'pageTitle', title: '文章标题', width: 300 },
					    { field: 'contentAttr', title: '文章属性', width: 100 },
					    { field: 'isPush', title: '发布状态', width: 60, sortable: true, align: 'center', formatter:function(value,row){
					    	if(value == 0){return "<font color='#00CC00'>已发</font>";}
					    	else if(value == 1){return "<font color='red'>未发</font>";}
					    }},
					    { field: 'email', title: '邮箱地址', width: 200, formatter: function(value, row) {
					    	return $.string.format("<a href='javascript:alert(\"\");' class='clickLInk ext_email'>{0}</a>", value) ;
					    } },
					    { field: 'created', title: '创建时间', width: 140 },
		 			    { field: 'createName', title: '创建者', width: 140 },
		 			    { field: 'modifyDate', title: '最后修改时间', width: 140 },
		 			    { field: 'modifyName', title: '修改者', width: 140 }
					]],
					onLoadSuccess: function(node, data) {
						$.fn.datagrid.extensions.onLoadSuccess.apply(this, arguments);
						$dg.datagrid('unselectAll');$dg.datagrid('clearSelections');
					}
				}) ;
		    }
		});    
    });
    
    
    function form_edit(form) {
    	if("E" == form) {
			var node = $dg.datagrid('getSelected');
			if (node) {
				$.webapp.open($.webapp.root + "/admin/site/doc/doc_form_UI.do?id="+id) ;
			} else {
				alertify.warning("请选择一条记录！"); return ;
			}
		} else {
	    	var node = $tree.tree('getSelected');
			if(node){
				$.webapp.open($.webapp.root + "/admin/site/doc/doc_form_UI.do?pid="+node.pid) ;
			} else {
				alertify.warning("请选择栏目！");
			}
		}
    }
    function del() {
    	var node = $tree.tree('getSelected');
		if(node){
			$.messager.confirm("该操作不可逆，您确定要进行该操作？", function (c) { 
				if(c) {
					$.easyui.loading({ msg: "数据删除中，请稍等..." });
					$.post($.webapp.root + "/admin/site/doc/delete.do", {id:node.id}, function(result) {
						if (result.status) {
							$("#form").form("clear");
							$tree.tree('reload');$.easyui.loaded();
							alertify.success(result.msg);
						} else {
							$.easyui.loaded();alertify.error(result.msg);
						}
					}, 'json').error(function(){$.easyui.loaded();});
				} else {}
			});
		} else {
			alertify.warning("请选择一条记录！");
		}
    }
    
    </script>
</head>

<body>
	<div class="easyui-layout" data-options="fit:true">
		
		<div data-options="region:'west',split:true" style="width:330px;border-top:none;">
			<div class="easyui-layout" data-options="fit:true"> 
				<div data-options="region:'center',border:false,iconCls:'icon-hamburg-category'" title="栏目列表">
					<div id="tree"></div>
				</div>
			</div>
		</div>
		
		<div data-options="region:'center',border:false">
			<div class="easyui-layout" data-options="fit:true">
			
				<div data-options="region: 'north', split: false, border: true" style="border-top:none;height: 33px;">
	                <div class="easyui-toolbar">
	                    <a onClick="form_edit();" class="easyui-linkbutton" data-options="plain: true, iconCls: 'ext_add'">新增</a>
	                    <a onClick="form_edit('E')" class="easyui-linkbutton" data-options="plain: true, iconCls: 'ext_save'">编辑</a>
	                    <a onClick="del()" class="easyui-linkbutton" data-options="plain: true, iconCls: 'ext_remove'">删除</a>
	                    <a onClick="del()" class="easyui-linkbutton" data-options="plain: true, iconCls: 'ext_reload'">刷新</a>
	                </div>
	            </div>
				<div data-options="region:'center'">
					<div id="dg"></div>
				</div>
				
			</div>
		</div>
		
	</div>
    
</body>
</html>



